home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / bash / bash_108 / bash-108.zoo / bash-1.08 / longest_sig.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-14  |  1.4 KB  |  54 lines

  1. /* The answer to this question is 24. */
  2. #include <stdio.h>
  3. #include <signal.h>
  4.  
  5. /* Copyright (C) 1987,1989 Free Software Foundation, Inc.
  6.  
  7. This file is part of GNU Bash, the Bourne Again SHell.
  8.  
  9. Bash is free software; you can redistribute it and/or modify it under
  10. the terms of the GNU General Public License as published by the Free
  11. Software Foundation; either version 1, or (at your option) any later
  12. version.
  13.  
  14. Bash is distributed in the hope that it will be useful, but WITHOUT ANY
  15. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  17. for more details.
  18.  
  19. You should have received a copy of the GNU General Public License along
  20. with Bash; see the file COPYING.  If not, write to the Free Software
  21. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  22.  
  23. main (argc, argv)
  24.      int argc;
  25.      char **argv;
  26. {
  27.   extern char *sys_siglist[];
  28.   
  29.   int longest, length = 0;
  30.   int i;
  31.  
  32.   for (i = 0; i < NSIG; i++) {
  33.     printf ("%s\n", sys_siglist[i]);
  34.     if (strlen (sys_siglist[i]) > length) {
  35.       longest = i;
  36.       length = strlen (sys_siglist[i]);
  37.     }
  38.   }
  39.  
  40.   if (argc = 1) {
  41.     printf ("The longest one is %d:\"%s\", which is %d chars in length.\n",
  42.         longest, sys_siglist[longest], length);
  43.   } else {
  44.     printf ("%d", length);
  45.   }
  46. }
  47.  
  48. /*
  49.  * Local variables:
  50.  * compile-command: "cc -o longest_signal_name longest_signal_name.c"
  51.  * end:
  52.  */
  53.  
  54.